<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp" %>
<html>
<head>
<%@include file="/common/meta.jsp" %>
<%@include file="/common/extjs.jsp" %>
<%@include file="/common/ec.jsp" %>
<script type="text/javascript" src="${ctx}/scripts/utils.js"></script>
</head>
<body>
<script type="text/javascript">
/**
 * 提交表单
 */
function submitForm(){
	$("#queryForm").submit();
}

function unsealUser(formid, msg){
	var checked = false;
	$('input').each(function(i, item) {
		if (item.checked && item.id == 'selectedItems') {
			checked = true;
		}
	});
	if (!checked) {
		alert('请至少选择一个用户');
		return;
	}

	if (confirm(msg)) {
		$('#ec').attr("action", $('#' + formid).attr("action"));		
		//ec.from里面已经包含model.type项,不相信查看源代码
		$('#ec').submit();
	} 
}
</script>
<s:form action="user/remove" id="removeForm"></s:form>
<s:form action="user/unsealUser" id="unsealForm"></s:form>
<div class="x-panel">
  <div class="x-panel-header">系统用户管理</div>
  <div class="x-toolbar">
    <table width="100%" style="line-height: 25px;">  
      <tr>
        <td> 
          <form id="queryForm" action="index.do">
          &nbsp;用户名：<s:textfield id="userLoginId" name="model.loginId" size="15"/>&nbsp;&nbsp;
          &nbsp;姓　名：<s:textfield id="userName" name="model.name" size="15"/>&nbsp;&nbsp;
          &nbsp;状　态：<s:select id="userStatus" name="model.status" list='#{"1":"可用","0":"禁用"}' onchange="submitForm()"/>&nbsp;
          &nbsp;<s:submit value="查询" cssClass="button" />
          </form>
        </td>
        <td>
          <a href="${ctx}/security/user/edit.do">
          <img src="${ctx}/images/icons/add.gif"/> 新建</a></td>
        <td><span class="ytb-sep"></span></td>
        <td>
          <a href="#" onclick="onRemove({noneSelectedMsg:'请至少选择一个用户.',deleteFormId:'unsealForm', confirmMsg:'确认要启用这些用户吗？'})">
          <img src="${ctx}/images/exticons/recommend.gif"/> 启用</a></td>
        <td><span class="ytb-sep"></span></td>
        <td>
          <a href="#" onclick="unsealUser('removeForm','确认要禁用所选用户吗?')">
          <img src="${ctx}/images/icons/delete.gif"/> 禁用</a></td>
        <td>
        <span class="ytb-sep"></span></td>
        <td>
          <a href="${ctx}/security/user/index.do">
          <img src="${ctx}/images/exticons/refresh.gif"/> 刷新</a></td>
      </tr>
    </table>
    </div>   
    <div class="x-panel-body">
    <div>
	<ec:table items="items" var="item" retrieveRowsCallback="limit" sortRowsCallback="limit" 
		action="index.do"
		useAjax="true" doPreload="false"
		maxRowsExported="10000000" 
		pageSizeList="15,50,100" 
		editable="false" 
		sortable="false"	
		rowsDisplayed="15"	
		generateScript="true"	
		resizeColWidth="false"	
		classic="false"	
		width="100%" 	
		height="400px"	
		minHeight="400"
		toolbarContent="navigation|pagejump|pagesize|refresh|extend|status"   
	>
	<ec:row>
	    <ec:column width="40" property="_s" title="选择" sortable="false" style="text-align:center">
	    	<input type="checkbox" name="selectedItems" id="selectedItems" value="${item.id}" class="checkbox"/>
	    </ec:column>
		<ec:column width="120" property="loginId" title="用户名" />
		<ec:column width="100" property="name" title="姓名" />
		<ec:column width="120" property="dept.name" title="部门" />
		<ec:column width="120" property="type" title="用户类别" mappingItem="typeMap"/>
		<ec:column width="100" property="mobile" title="手机" />
		<ec:column width="90" property="createTime" title="创建日期" cell="date" format="yyyy-MM-dd" style="text-align:center"/>
		<ec:column width="50" property="_status" title="状态" style="text-align:center;">
		  <s:if test="#attr.item.status == 1">
		  	<img src="${ctx}/images/icons/accept.gif" title="可用">
		  </s:if>
		  <s:elseif test="#attr.item.status == 0">
		    <img src="${ctx}/images/grid/clear.gif" title="禁用">
		  </s:elseif>
		</ec:column>
		<ec:column width="40" property="_1" title="角色" style="text-align:center" sortable='false' tipTitle="分配角色">
		  <a href="#" onclick="javascript:assignRoles('${item.id}')">
		  <img src="${ctx}/images/icons/flowpic.gif"></a>
		</ec:column>
		<ec:column width="40" property="_2" title="操作" style="text-align:center"  sortable="false">
		   <a href="edit.do?model.id=${item.id}" title="编辑">
		     <img src="${ctx}/images/icons/modify.gif"></a>
		</ec:column>
	</ec:row>
	<ec:extendbar>
	  <div style="display: none;">
	  </div>
	</ec:extendbar>
	</ec:table>
	</div>
	</div>
</div>


<div id="win" class="x-hidden">
    <div class="x-window-header">角色列表</div>
    <div id="role_grid"></div>
</div>
<script type="text/javascript" src="${ctx}/pages/admin/security/user/user.js">
</script>
<div id='load-mask'></div>
</body>
</html>